<!DOCTYPE html>
<html lang="en" class="no-js" xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<head th:include="admin/layout">
</head>
<body class="gray-bg" data-controller="company" data-action="list">
	<div class="wrapper wrapper-content" style="padding: 60px;">
   		 <div id="page-wrapper" style="min-height: 416px;">
            <div class="row">
                <div class="col-lg-12">
                    <h4 class="page-header">修改密码</h4>
                </div>
                <!-- /.col-lg-12 -->
            </div>
             <form id="pass_form" class="form-horizontal m-t" style="width:70%;">
          			<div class="col-md-12">
    					<div class="form-group">
        					<label class="col-sm-3 control-label">原密码：</label>
        					<div class="col-sm-9">
            					<input type="password" class="form-control" id="oldPassword" name="oldPassword" placeholder="请输入原密码"/>
        					</div>
    					</div>
    					<div class="form-group">
        					<label class="col-sm-3 control-label">新密码：</label>
        					<div class="col-sm-9">
            					<input type="password" class="form-control" id="newPassword" name="newPassword" placeholder="请输入新密码"/>
        					</div>
    					</div>
    					<div class="form-group">
        					<label class="col-sm-3 control-label">确认新密码：</label>
        					<div class="col-sm-9">
            					<input type="password" class="form-control" id="confirmPassword" name="confirmPassword" placeholder="请输入确认密码"/>
        					</div>
    					</div>
					</div>
						<div class="form-group">
        					<div class="col-sm-12 col-sm-offset-3">
            					<button class="btn btn-primary" onclick="save();" type="button">保存</button>
            					<button class="btn btn-white" type="button" onclick="back();">取消</button>
        					</div>
    					</div>
      		</form>
     </div>
    </div>
    <script type="text/javascript">
    	function save(){
    		var newPassword=$("#newPassword").val();
    		var confirmPassword=$("#confirmPassword").val();
    		if(newPassword==""||confirmPassword==""){
    			alert("字段不能为空！");
    			return;
    		}
    		if(newPassword!=confirmPassword){
    			alert("两次密码输入不一致！");
    			return;
    		}
    		$.ajax({
    			url:'/admin/updatepass',
    			async:true,
    			data:$('#pass_form').serialize(),
    			dataType: "json",
    			success:function(data){
    				if(data.success ==true){
    					alert(data.memo);
    					window.location.href = "/admin/index";
    				}else{
    					alert('操作失败!失败原因：'+data.memo);
    				}
    			},
    			error:function(){
    				alert('操作失败！系统异常');
    			},
    			complete:function(){
    				
    			}
    		});
    	}
    	function back(){
    		history.back();
    	}
    </script>
</body>
</html>